package com.honghu.villagepost.adapter

import com.honghu.villagepost.R
import com.honghu.villagepost.entity.Select
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

/**
 * @author: mqwang
 * @create: 3/3/21 3:50 PM
 * @Description:
 */
class RecRightAdapter : BaseQuickAdapter<Select, BaseViewHolder>(R.layout.adapter_rec_right) {
    override fun convert(helper: BaseViewHolder?, item: Select?) {
        if (item!!.isSelect) {
            helper!!.setVisible(R.id.iv_select, true)
            helper!!.setTextColor(R.id.tv_content, mContext.getResources().getColor(R.color.colorOrange))
        } else {
            helper!!.setVisible(R.id.iv_select, false)
            helper!!.setTextColor(R.id.tv_content, mContext.getResources().getColor(R.color.colorTextNormal))
        }
        helper.setText(R.id.tv_content, item.name + "  " + item.startTime + "-" + item.endTime)

    }

    fun selectItem(position: Int){
        for (element in data){
            element.isSelect = false
        }
        data.get(position).isSelect = true
        notifyDataSetChanged()
    }
}